/*
 * FriendInference.java
 *
 * Created on 6 f�vrier 2008, 10:29
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package br.great.functionalCore;

import br.great.beans.FacebookProfile;
import br.great.beans.PossibleTag;
import br.great.config.PhotomapConstants;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;


/**
 *
 * @author defautce
 */
public class FriendInference
{

//Se data de aniversário = data da foto, gera tag MYBIRTHDAY com peso 1
    //Se data de aniversário do amigo = data da foto, gera tag FRIENDBIRTHDAY + name com peso 0.5
    //Se amigo próximo, gera tag "nome do amigo" com peso 0.8
    //Se amigo próximo e aniversário, gera tag FRIENDBIRTHDAY + nome com peso 1
    ArrayList<PossibleTag> vtPossibleTag;
    //Primeiro elemento da lista é o perfil do usuário, os demais elementos são seus amigos
    ArrayList<FacebookProfile> vtFacebookProfile;

    /** Creates a new instance of FriendInference */
    public FriendInference(String name) throws MalformedURLException, IOException
    {
        vtPossibleTag = new ArrayList<PossibleTag>();
        ObtainsFriendInference obf = new ObtainsFriendInference();
        vtFacebookProfile = obf.getFacebookInstances(name);
    }

    //Esse método guarda os dados gerados pelos outros métodos para
    //gerar uma lista de PossibleTags para uma foto específica.
    public ArrayList<PossibleTag> generateTagsFromFacebookPT(Date photoDate, Vector<String> bluetooth) throws FileNotFoundException, IOException, ParseException
    {
            vtPossibleTag = new ArrayList<PossibleTag>();
            //Usa uma lista de PossibleTags auxiliar para
            //guardar todos os PossibleTags gerados, até os que tem precisão 0.0
            ArrayList<PossibleTag> aux = new ArrayList<PossibleTag>();
            PossibleTag user = new PossibleTag();
            user = generateUserBirthdayTag(photoDate, vtFacebookProfile.get(0));
            aux.add(user);
            
            for(int i=1; i < vtFacebookProfile.size(); i++){
                PossibleTag friendbirth = new PossibleTag();
                friendbirth = generateFriendBirthdayTag(photoDate, vtFacebookProfile.get(i), bluetooth);
                aux.add(friendbirth);

                PossibleTag near = new PossibleTag();
            near = generateNearFriendsTag(bluetooth, vtFacebookProfile.get(i));
            aux.add(near);
        }
            int size = aux.size();
            //Guarda em vtPossibleTag os PossibleTags que estavam na lista auxiliar
            //e que tem precisão diferente de 0.0, deixando assim somente
            //os PossibleTags úteis.
            for(int i=0; i < size; i++)
            {
                if((aux.get(i).getPrecision() != 0) && (aux.get(i).getSufix().equals("TIME")))
                {
                    vtPossibleTag.add(aux.get(i));
                }

                if((aux.get(i).getPrecision() != 0) && (aux.get(i).getSufix().equals("NEAR")))
                {
                    vtPossibleTag.add(aux.get(i));
                }
            }

    return vtPossibleTag;
}
    
             
    

    //Esse método gera um objeto PossibleTag com precisão 1.0
    //se a data da foto é igual ao aniversário do usuário e
    //gera um objeto PossibleTag com precisão 0.7 se a data da foto
    //tem um dia a mais ou a menos que o aniversário do usuário.
    protected PossibleTag generateUserBirthdayTag(Date photo_date, FacebookProfile fp) throws FileNotFoundException, IOException, ParseException
    {

            int BirthDay;
            int BirthMonth;
            try{
                    BirthDay = fp.getBirthday().getDate();
                    BirthMonth = fp.getBirthday().getMonth()+1;
                } catch(NullPointerException e)
                {
                    BirthDay = 0;
                    BirthMonth = 0;
                }
            int PhotoDay = photo_date.getDate();
            int PhotoMonth = photo_date.getMonth()+1;
            int PhotoYear = photo_date.getYear();

            PossibleTag userBirth = new PossibleTag();

                if((PhotoMonth == BirthMonth))
                {
                    if(PhotoDay == BirthDay)
                    {
                            userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                            userBirth.setPrecision(1);
                            userBirth.setSufix("TIME");
                    }
                    else
                    {
                        if((PhotoDay == BirthDay + 1) || (PhotoDay == BirthDay - 1))
                        {
                            userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                            userBirth.setPrecision(0.7);
                            userBirth.setSufix("TIME");
                        }
                    }
                }
                else
                {
                    if((PhotoMonth == 2 && BirthMonth == 1) && (PhotoDay == 1 && BirthDay == 31))
                    {
                            userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                            userBirth.setPrecision(0.7);
                            userBirth.setSufix("TIME");

                    }
                    else
                    {
                        if((PhotoMonth == 1 && BirthMonth == 2) && (PhotoDay == 31 && BirthDay == 1))
                        {
                            userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                            userBirth.setPrecision(0.7);
                            userBirth.setSufix("TIME");
                        }


                        else
                        {
                             if((PhotoMonth == 2 && BirthMonth == 3) && BirthDay == 1)
                             {
                                 if(PhotoYear%4 == 0)
                                 {
                                     if(PhotoDay == 29)
                                     {
                                        userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                        userBirth.setPrecision(0.7);
                                        userBirth.setSufix("TIME");
                                     }
                                 }
                             else
                             {
                                 if(PhotoDay == 28)
                                 {
                                    userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                    userBirth.setPrecision(0.7);
                                    userBirth.setSufix("TIME");
                                 }
                             }
                             }
                         else
                         {
                             if((PhotoMonth == 3 && PhotoDay == 1) && BirthMonth == 2)
                             {
                                if(BirthDay == 29)
                                {
                                    userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                    userBirth.setPrecision(0.7);
                                    userBirth.setSufix("TIME");
                                }
                             else
                             {
                                if(PhotoYear%4 != 0)
                                {
                                    if(BirthDay == 28)
                                    {
                                        userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                        userBirth.setPrecision(0.7);
                                        userBirth.setSufix("TIME");
                                    }
                                }
                             }
                             }
                             else
                             {
                                if((PhotoMonth == 3 && BirthMonth == 4) && (PhotoDay == 31 && BirthDay == 1))
                                {
                                    userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                    userBirth.setPrecision(0.7);
                                    userBirth.setSufix("TIME");
                                }
                                else
                                {
                                    if((PhotoMonth == 4 && BirthMonth == 3) && (PhotoDay == 1 && BirthDay == 31))
                                    {
                                        userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                        userBirth.setPrecision(0.7);
                                        userBirth.setSufix("TIME");
                                    }
                                    else
                                    {
                                        if((PhotoMonth == 4 && BirthMonth == 5) && (PhotoDay == 30 && BirthDay == 1))
                                        {
                                            userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                            userBirth.setPrecision(0.7);
                                            userBirth.setSufix("TIME");
                                        }
                                        else
                                        {
                                           if((PhotoMonth == 5 && BirthMonth == 4) && (PhotoDay == 1 && BirthDay == 30))
                                           {
                                                userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                userBirth.setPrecision(0.7);
                                                userBirth.setSufix("TIME");
                                           }
                                           else
                                           {
                                               if((PhotoMonth == 5 && BirthMonth == 6) && (PhotoDay == 31 && BirthDay == 1))
                                               {
                                                    userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                    userBirth.setPrecision(0.7);
                                                    userBirth.setSufix("TIME");
                                               }
                                               else
                                               {
                                                   if((PhotoMonth == 6 && BirthMonth == 5) && (PhotoDay == 1 && BirthDay == 31))
                                                   {
                                                        userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                        userBirth.setPrecision(0.7);
                                                        userBirth.setSufix("TIME");
                                                   }
                                                   else
                                                   {
                                                       if((PhotoMonth == 6 && BirthMonth == 7) && (PhotoDay == 30 && BirthDay == 1))
                                                       {
                                                            userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                            userBirth.setPrecision(0.7);
                                                            userBirth.setSufix("TIME");
                                                        }
                                                        else
                                                        {
                                                           if((PhotoMonth == 7 && BirthMonth == 6) && (PhotoDay == 1 && BirthDay == 30))
                                                           {
                                                                userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                userBirth.setPrecision(0.7);
                                                                userBirth.setSufix("TIME");
                                                            }
                                                            else
                                                            {
                                                               if((PhotoMonth == 7 && BirthMonth == 8) && (PhotoDay == 31 && BirthDay == 1))
                                                               {
                                                                    userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                    userBirth.setPrecision(0.7);
                                                                    userBirth.setSufix("TIME");
                                                               }
                                                               else
                                                               {
                                                                   if((PhotoMonth == 8 && BirthMonth == 7) && (PhotoDay == 1 && BirthDay == 31))
                                                                   {
                                                                        userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                        userBirth.setPrecision(0.7);
                                                                        userBirth.setSufix("TIME");
                                                                   }
                                                                   else
                                                                   {
                                                                       if((PhotoMonth == 8 && BirthMonth == 9) && (PhotoDay == 31 && BirthDay == 1))
                                                                       {
                                                                            userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                            userBirth.setPrecision(0.7);
                                                                            userBirth.setSufix("TIME");
                                                                       }
                                                                       else
                                                                       {
                                                                           if((PhotoMonth == 9 && BirthMonth == 8) && (PhotoDay == 1 && BirthDay == 31))
                                                                           {
                                                                                userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                                userBirth.setPrecision(0.7);
                                                                                userBirth.setSufix("TIME");
                                                                           }
                                                                           else
                                                                           {
                                                                               if((PhotoMonth == 9 && BirthMonth == 10) && (PhotoDay == 30 && BirthDay == 1))
                                                                               {
                                                                                    userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                                    userBirth.setPrecision(0.7);
                                                                                    userBirth.setSufix("TIME");
                                                                               }
                                                                               else
                                                                               {
                                                                                   if((PhotoMonth == 10 && BirthMonth == 9) && (PhotoDay == 1 && BirthDay == 30))
                                                                                   {
                                                                                        userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                                        userBirth.setPrecision(0.7);
                                                                                        userBirth.setSufix("TIME");
                                                                                   }
                                                                                   else
                                                                                   {
                                                                                       if((PhotoMonth == 10 && BirthMonth == 11) && (PhotoDay == 31 && BirthDay == 1))
                                                                                       {
                                                                                            userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                                            userBirth.setPrecision(0.7);
                                                                                            userBirth.setSufix("TIME");
                                                                                       }
                                                                                       else
                                                                                       {
                                                                                           if((PhotoMonth == 11 && BirthMonth == 10) && (PhotoDay == 1 && BirthDay == 31))
                                                                                           {
                                                                                                userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                                                userBirth.setPrecision(0.7);
                                                                                                userBirth.setSufix("TIME");
                                                                                           }
                                                                                           else
                                                                                           {
                                                                                               if((PhotoMonth == 11 && BirthMonth == 12) && (PhotoDay == 30 && BirthDay == 1))
                                                                                               {
                                                                                                    userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                                                    userBirth.setPrecision(0.7);
                                                                                                    userBirth.setSufix("TIME");
                                                                                               }
                                                                                               else
                                                                                               {
                                                                                                   if((PhotoMonth == 12 && BirthMonth == 11) && (PhotoDay == 1 && BirthDay == 30))
                                                                                                   {
                                                                                                        userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                                                        userBirth.setPrecision(0.7);
                                                                                                        userBirth.setSufix("TIME");
                                                                                                   }
                                                                                                   else
                                                                                                   {
                                                                                                       if((PhotoMonth == 12 && BirthMonth == 1) && (PhotoDay == 31 && BirthDay == 1))
                                                                                                       {
                                                                                                            userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                                                            userBirth.setPrecision(0.7);
                                                                                                            userBirth.setSufix("TIME");
                                                                                                       }
                                                                                                       else
                                                                                                       {
                                                                                                           if((PhotoMonth == 1 && BirthMonth == 12) && (PhotoDay == 1 && BirthDay == 31))
                                                                                                           {
                                                                                                                userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                                                                userBirth.setPrecision(0.7);
                                                                                                                userBirth.setSufix("TIME");
                                                                                                           }
                                                                                                           else
                                                                                                           {
                                                                                                              userBirth.setValue(PhotomapConstants.MYBIRTHDAY);
                                                                                                              userBirth.setPrecision(0);
                                                                                                              userBirth.setSufix("TIME");
                                                                                                           }
                                                                                                       }
                                                                                                   }
                                                                                               }
                                                                                           }
                                                                                       }
                                                                                   }
                                                                               }
                                                                            }
                                                                        }
                                                                     }
                                                                   }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            return userBirth;
    }

    //Esse método gera um objeto PossibleTag com precisão 1.0
    //se a data da foto é igual ao aniversário do amigo do usuário e
    //o bluetooth desse amigo está próximo,
    //gera um objeto PossibleTag com precisão 0.9 se a data da foto é
    //igual ao aniversário do amigo do usuário e o bluetooth desse amigo não está próximo e
    //gera um objeto PossibleTag com precisão 0.5 se a data da foto
    //tem um dia a mais ou a menos que o aniversário do amigo do usuário.
   protected PossibleTag generateFriendBirthdayTag(Date photo_date, FacebookProfile fp, Vector<String> bluetoothPhoto) throws FileNotFoundException, IOException, ParseException
   {

        //Capturando amigos do usuário

        PossibleTag friendBirth = new PossibleTag();
        PossibleTag bluetooth = new PossibleTag();

        int bt = bluetoothPhoto.size();

        for(int j=0; j<bt; j++)
                {
                    if(bluetoothPhoto.get(j).equalsIgnoreCase(fp.getBluetooth()) == true)
                    {
                        bluetooth.setValue(fp.getName());
                        bluetooth.setPrecision(1);
                        bluetooth.setSufix("NEAR");
                    }
    }

      //Capturando aniversário dos amigos do usuario
      int BirthDay;
      int BirthMonth;
       try{
        BirthDay = fp.getBirthday().getDate();
        BirthMonth = fp.getBirthday().getMonth()+1;
       } catch(NullPointerException e){
           BirthDay = 0;
           BirthMonth = 0;
       }
        int PhotoDay = photo_date.getDate();
        int PhotoMonth = photo_date.getMonth()+1;
        int PhotoYear = photo_date.getYear();

        String name = fp.getName();

        if((PhotoMonth == BirthMonth))
            {
                if(PhotoDay == BirthDay)
                {
                    //checa se bluetooth do amigo está próximo
                        if(bluetooth.getPrecision() == 1)
                        {
                            friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                            friendBirth.setPrecision(1);
                            friendBirth.setSufix("TIME");
                        }
                        else
                        {
                            friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                            friendBirth.setPrecision(0.9);
                            friendBirth.setSufix("TIME");
                        }
                }
                else
                {
                    if((PhotoDay == BirthDay + 1) || (PhotoDay == BirthDay - 1))
                    {
                        friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                        friendBirth.setPrecision(0.5);
                        friendBirth.setSufix("TIME");
                    }
                }
            }
            else
            {
                if((PhotoMonth == 2 && BirthMonth == 1) && (PhotoDay == 1 && BirthDay == 31))
                {
                        friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                        friendBirth.setPrecision(0.5);
                        friendBirth.setSufix("TIME");

                }
                else
                {
                    if((PhotoMonth == 1 && BirthMonth == 2) && (PhotoDay == 31 && BirthDay == 1))
                    {
                        friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                        friendBirth.setPrecision(0.5);
                        friendBirth.setSufix("TIME");
                    }


                    else
                    {
                         if((PhotoMonth == 2 && BirthMonth == 3) && BirthDay == 1)
                         {
                             if(PhotoYear%4 == 0)
                             {
                                 if(PhotoDay == 29)
                                 {
                                    friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                    friendBirth.setPrecision(0.5);
                                    friendBirth.setSufix("TIME");
                                 }
                             }
                         else
                         {
                             if(PhotoDay == 28)
                             {
                                friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                friendBirth.setPrecision(0.5);
                                friendBirth.setSufix("TIME");
                             }
                         }
                         }
                     else
                     {
                         if((PhotoMonth == 3 && PhotoDay == 1) && BirthMonth == 2)
                         {
                            if(BirthDay == 29)
                            {
                                friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                friendBirth.setPrecision(0.5);
                                friendBirth.setSufix("TIME");
                            }
                         else
                         {
                            if(PhotoYear%4 != 0)
                            {
                                if(BirthDay == 28)
                                {
                                    friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                    friendBirth.setPrecision(0.5);
                                    friendBirth.setSufix("TIME");
                                }
                            }
                         }
                         }
                         else
                         {
                            if((PhotoMonth == 3 && BirthMonth == 4) && (PhotoDay == 31 && BirthDay == 1))
                            {
                                friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                friendBirth.setPrecision(0.5);
                                friendBirth.setSufix("TIME");
                            }
                            else
                            {
                                if((PhotoMonth == 4 && BirthMonth == 3) && (PhotoDay == 1 && BirthDay == 31))
                                {
                                    friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                    friendBirth.setPrecision(0.5);
                                    friendBirth.setSufix("TIME");
                                }
                                else
                                {
                                    if((PhotoMonth == 4 && BirthMonth == 5) && (PhotoDay == 30 && BirthDay == 1))
                                    {
                                        friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                        friendBirth.setPrecision(0.5);
                                        friendBirth.setSufix("TIME");
                                    }
                                    else
                                    {
                                       if((PhotoMonth == 5 && BirthMonth == 4) && (PhotoDay == 1 && BirthDay == 30))
                                       {
                                            friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                            friendBirth.setPrecision(0.5);
                                            friendBirth.setSufix("TIME");
                                       }
                                       else
                                       {
                                           if((PhotoMonth == 5 && BirthMonth == 6) && (PhotoDay == 31 && BirthDay == 1))
                                           {
                                                friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                friendBirth.setPrecision(0.5);
                                                friendBirth.setSufix("TIME");
                                           }
                                           else
                                           {
                                               if((PhotoMonth == 6 && BirthMonth == 5) && (PhotoDay == 1 && BirthDay == 31))
                                               {
                                                    friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                    friendBirth.setPrecision(0.5);
                                                    friendBirth.setSufix("TIME");
                                               }
                                               else
                                               {
                                                   if((PhotoMonth == 6 && BirthMonth == 7) && (PhotoDay == 30 && BirthDay == 1))
                                                   {
                                                        friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                        friendBirth.setPrecision(0.5);
                                                        friendBirth.setSufix("TIME");
                                                    }
                                                    else
                                                    {
                                                       if((PhotoMonth == 7 && BirthMonth == 6) && (PhotoDay == 1 && BirthDay == 30))
                                                       {
                                                            friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                            friendBirth.setPrecision(0.5);
                                                            friendBirth.setSufix("TIME");
                                                        }
                                                        else
                                                        {
                                                           if((PhotoMonth == 7 && BirthMonth == 8) && (PhotoDay == 31 && BirthDay == 1))
                                                           {
                                                                friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                friendBirth.setPrecision(0.5);
                                                                friendBirth.setSufix("TIME");
                                                           }
                                                           else
                                                           {
                                                               if((PhotoMonth == 8 && BirthMonth == 7) && (PhotoDay == 1 && BirthDay == 31))
                                                               {
                                                                    friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                    friendBirth.setPrecision(0.5);
                                                                    friendBirth.setSufix("TIME");
                                                               }
                                                               else
                                                               {
                                                                   if((PhotoMonth == 8 && BirthMonth == 9) && (PhotoDay == 31 && BirthDay == 1))
                                                                   {
                                                                        friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                        friendBirth.setPrecision(0.5);
                                                                        friendBirth.setSufix("TIME");
                                                                   }
                                                                   else
                                                                   {
                                                                       if((PhotoMonth == 9 && BirthMonth == 8) && (PhotoDay == 1 && BirthDay == 31))
                                                                       {
                                                                            friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                            friendBirth.setPrecision(0.5);
                                                                            friendBirth.setSufix("TIME");
                                                                       }
                                                                       else
                                                                       {
                                                                           if((PhotoMonth == 9 && BirthMonth == 10) && (PhotoDay == 30 && BirthDay == 1))
                                                                           {
                                                                                friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                                friendBirth.setPrecision(0.5);
                                                                                friendBirth.setSufix("TIME");
                                                                           }
                                                                           else
                                                                           {
                                                                               if((PhotoMonth == 10 && BirthMonth == 9) && (PhotoDay == 1 && BirthDay == 30))
                                                                               {
                                                                                    friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                                    friendBirth.setPrecision(0.5);
                                                                                    friendBirth.setSufix("TIME");
                                                                               }
                                                                               else
                                                                               {
                                                                                   if((PhotoMonth == 10 && BirthMonth == 11) && (PhotoDay == 31 && BirthDay == 1))
                                                                                   {
                                                                                        friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                                        friendBirth.setPrecision(0.5);
                                                                                        friendBirth.setSufix("TIME");
                                                                                   }
                                                                                   else
                                                                                   {
                                                                                       if((PhotoMonth == 11 && BirthMonth == 10) && (PhotoDay == 1 && BirthDay == 31))
                                                                                       {
                                                                                            friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                                            friendBirth.setPrecision(0.5);
                                                                                            friendBirth.setSufix("TIME");
                                                                                       }
                                                                                       else
                                                                                       {
                                                                                           if((PhotoMonth == 11 && BirthMonth == 12) && (PhotoDay == 30 && BirthDay == 1))
                                                                                           {
                                                                                                friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                                                friendBirth.setPrecision(0.5);
                                                                                                friendBirth.setSufix("TIME");
                                                                                           }
                                                                                           else
                                                                                           {
                                                                                               if((PhotoMonth == 12 && BirthMonth == 11) && (PhotoDay == 1 && BirthDay == 30))
                                                                                               {
                                                                                                    friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                                                    friendBirth.setPrecision(0.5);
                                                                                                    friendBirth.setSufix("TIME");
                                                                                               }
                                                                                               else
                                                                                               {
                                                                                                   if((PhotoMonth == 12 && BirthMonth == 1) && (PhotoDay == 31 && BirthDay == 1))
                                                                                                   {
                                                                                                        friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                                                        friendBirth.setPrecision(0.5);
                                                                                                        friendBirth.setSufix("TIME");
                                                                                                   }
                                                                                                   else
                                                                                                   {
                                                                                                       if((PhotoMonth == 1 && BirthMonth == 12) && (PhotoDay == 1 && BirthDay == 31))
                                                                                                       {
                                                                                                            friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                                                            friendBirth.setPrecision(0.5);
                                                                                                            friendBirth.setSufix("TIME");
                                                                                                       }
                                                                                                       else
                                                                                                       {
                                                                                                          friendBirth.setValue(PhotomapConstants.FRIENDBIRTHDAY + name);
                                                                                                          friendBirth.setPrecision(0);
                                                                                                          friendBirth.setSufix("TIME");
                                                                                                       }
                                                                                                   }
                                                                                               }
                                                                                           }
                                                                                       }
                                                                                   }
                                                                               }
                                                                           }
                                                                        }
                                                                    }
                                                                 }
                                                               }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

  return friendBirth;
   }

    //Esse método gera um objeto PossibleTag com precisão 1.0
    //se bluetooth do amigo do usuário está próximo.
    protected PossibleTag generateNearFriendsTag(Vector<String> bluetooth, FacebookProfile fp) throws FileNotFoundException, IOException, ParseException
    {
          //Capturando amigos do usuário

          int bt = bluetooth.size();

          PossibleTag near = new PossibleTag();

                for(int j=0; j<bt; j++)
                {
                    if(bluetooth.get(j).equalsIgnoreCase(fp.getBluetooth()) == true)
                    {
                        near.setValue(fp.getName());
                        near.setPrecision(1);
                        near.setSufix("NEAR");

                    }


    }
          return near;
    }
}
